﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using MovieRental.DataInterfaces;
using MovieRental.XmlDataProviderCore;
using MovieRental.GeneralDataExceptions;

namespace MovieRental.XmlRepositoryLibrary
{
    public class XmlRepositoryFactory : IRepositoryFactory
    {
        private XmlDataProvider _provider;

        public XmlRepositoryFactory()
        {
            _provider = XmlDataProvider.Initialize();
        }

        public void Reconnect()
        {
            _provider.Dispose();
            _provider = XmlDataProvider.Initialize();
        }

        public ICartDiscountRepository GetCartDiscountRepository()
        {            
            return new XmlCartDiscountRepository(_provider);
        }

        public ICustomerRepository GetCustomerRepository()
        {
            return new XmlCustomerRepository(_provider);
        }

        public IEditionRepository GetEditionRepository()
        {
            return new XmlEditionRepository(_provider);
        }

        public ILoanCartRepository GetLoanCartRepository()
        {
            return new XmlLoanCartRepository(_provider);
        }

        public IMediaTypeRepository GetMediaTypeRepository()
        {
            return new XmlMediaTypeRepository(_provider);
        }

        public IMovieRepository GetMovieRepository()
        {
            return new XmlMovieRepository(_provider);
        }

        public IPersonalDiscountRepository GetPersonalDiscountRepository()
        {
            return new XmlPersonalDiscountRepository(_provider);
        }

        public ITemporaryDiscountRepository GetTemporaryDiscountRepository()
        {
            return new XmlTemporaryDiscountRepository(_provider);
        }
    
    }
}
